package com.wwwarehouse.taskcenter.fragment.warehouse_reg;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.common.tools.rsa.StringUtils;
import com.wwwarehouse.taskcenter.R;

import de.greenrobot.event.EventBus;

/**
 * Created by clannad.shao on 2017/11/16.
 *
 * @author clannad_sk
 * @date 2017/11/16
 * 入库登记fragment
 */
public class WhouseRegSuccessFragment extends BaseFragment {

    private TextView idWareSucOwnerNameTv;
    private TextView idWareSucDateTimeTv;
    private TextView idWareSucBillTypeTv;
    private TextView idWareSucBillNumTv;
    private TextView idWareSucCarriageTv;
    private TextView idWareSucCarNumTv;
    private TextView idWareSucDriNameTv;
    private TextView idWareSucPhoneTv;
    private TextView idWareSucCompleteTv;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.task_center_warehouse_reg_success, container, false);
    }

    /**
     * initView
     *
     * @param savedInstanceState
     */
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Bundle bundle = getArguments();
        idWareSucOwnerNameTv = $(R.id.idWareSucOwnerNameTv);
        idWareSucDateTimeTv = $(R.id.idWareSucDateTimeTv);
        idWareSucBillTypeTv = $(R.id.idWareSucBillTypeTv);
        idWareSucBillNumTv = $(R.id.idWareSucBillNumTv);
        idWareSucCarriageTv = $(R.id.idWareSucCarriageTv);
        idWareSucCarNumTv = $(R.id.idWareSucCarNumTv);
        idWareSucDriNameTv = $(R.id.idWareSucDriNameTv);
        idWareSucPhoneTv = $(R.id.idWareSucPhoneTv);
        idWareSucCompleteTv = $(R.id.idWareSucCompleteTv);
        if(bundle != null){
            String owner = (String) bundle.get("owner");
            String dateTime = (String)bundle.get("dateTime");
            String billType = (String)bundle.get("billType");
            String billNum = (String)bundle.get("billNum");
            String carriage = (String)bundle.get("carriage");
            String carNo = (String)bundle.get("carNo");
            String driverName = (String)bundle.get("driverName");
            String driverPhone = (String)bundle.get("driverPhone");
            idWareSucOwnerNameTv.setText(StringUtils.isNullString(owner) ? "" : owner);
            idWareSucDateTimeTv.setText(StringUtils.isNullString(dateTime) ? "" : dateTime);
            idWareSucBillTypeTv.setText(StringUtils.isNullString(billType) ? "" : billType);
            idWareSucBillNumTv.setText(StringUtils.isNullString(billNum) ? "" : billNum);
            idWareSucCarriageTv.setText(StringUtils.isNullString(carriage) ? "" : carriage);
            idWareSucCarNumTv.setText(StringUtils.isNullString(carNo) ? "" : carNo);
            idWareSucDriNameTv.setText(StringUtils.isNullString(driverName) ? "" : driverName);
            idWareSucPhoneTv.setText(StringUtils.isNullString(driverPhone) ? "" : driverPhone);
        }
    }



    @Override
    public void onDestroy() {
        super.onDestroy();
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof WhouseRegSuccessFragment) {
            mActivity.setTitle(getString(R.string.warehouse_reg_authority_title));
        }
    }

    @Override
    public void requestDatas() {

    }
}
